import Cookies from 'js-cookie'
export default {
    showLoading: ({ commit }) => {
        commit('showLoading')
    },
    hideLoading: ({ commit }) => {
        commit('hideLoading')
    },
    showNav: ({ commit }) => {
        commit('showNav')
    },
    hideNav: ({ commit }) => {
        commit('hideNav')
    },
    setUserInfo: ({commit},userInfo) => {
        if (userInfo) {
            Cookies.set('userCode', userInfo)
        } else {
            Cookies.remove('userCode')
        }
        commit('setUserInfo', userInfo);
    },
    logout ({commit}) {
        return new Promise((resolve) => {
          commit('setUserInfo', '', { root: true })
          resolve()
        })
    },
    goods ({commit}, num = 0) {
        return new Promise(resolve => {
            commit('goodsum', num, {root: true})
            resolve()
        })
    }
}
